#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "guoshu.h"
#include "dlcw.h"
#include "admin_0.h"
#include <string.h>
#include <QChartView>
#include <QMessageBox>
#include <QStandardItemModel>
#include "value.h"
#define fixedColumn 9
#define colnum 0
#define colbrand 1
#define colname 2
#define colinmoney 3
#define coloutmoney 4
#define colcurnum 5
#define colindate 6
#define colexp 7
#define coloutdate 8

void MainWindow::inidata()
{
    QStringList headlist;
    headlist<<"产品编号"<<"果蔬名"<<"别名"<<"进价"<<"售价"<<"剩余数量"<<"进货日期"<<"保质期"<<"过期时间";
    themodel->setHorizontalHeaderLabels(headlist);
    FILE *fp=NULL;
    fp=fopen("data0","a+");
    if(fp==NULL) QMessageBox::warning(this,"err","查找文件失败");
    QStandardItem *noItem=new QStandardItem("没有已录入的商品");
    if(count==0){
        for(int i=0;i<=8;i++){
            noItem=new QStandardItem("没有已录入的商品");
            themodel->setItem(i,colnum,noItem);
        }
    }

}

void MainWindow::surveydata()//统计数据
{

}

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    setWindowTitle("库存查看");
    qsrand(QTime::currentTime().second());
    themodel=new QStandardItemModel(count,fixedColumn,this);
    inidata();
    ui->tableView->setModel(themodel);
    iniBarChart();
    buildBarChartA();
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_survey_triggered()
{
    surveydata();
}

void MainWindow::iniBarChart()
{
    QChart *chart=new QChart;
    chart->setTitle("piechart演示");
    chart->setAnimationOptions(QChart::SeriesAnimations);//动画效果
    ui->chartview_2->setChart(chart);
    ui->chartview_2->setRenderHint(QPainter::Antialiasing);
}

void MainWindow::buildBarChartA()
{

}

void MainWindow::on_action_triggered() // 返回管理员界面
{
    this->close();
    Admin_0 *ad=new Admin_0(this);
    ad->show();
}
